%include "pm.inc"
EXTERN print_string
global intr_entry

section .data
	intr_str: db "Interruption occured.", '\0'
	intr_str1: db "Exception occured.", '\0'
	intr_entry:
	%rep 8
	Gate SelectorCode32, intr_handle_noerror, 0, DA_386IGate      ;0~7,no error
	%endrep

	Gate SelectorCode32, intr_handle_error, 0, DA_386IGate        ;8,error

	Gate SelectorCode32, intr_handle_noerror, 0, DA_386IGate           ;9,no error

	%rep 5
	Gate SelectorCode32, intr_handle_error, 0, DA_386IGate             ;10~15,error
	%endrep

	%rep 17
	Gate SelectorCode32, intr_handle_noerror, 0, DA_386IGate			  ;16~32,no error
	%endrep

section .code
bits 32
intr_handle_noerror:
	push intr_str
	call print_string
	add esp, 4

	;Send EOI to OCW2
	mov al, 0x20
	out 0xa0, al;Slave
	out 0x20, al;Master

	iret

intr_handle_error:
	push intr_str1
	call print_string
	add esp, 4

	;Send EOI to OCW2
	mov al, 0x20
	out 0xa0, al;Slave
	out 0x20, al;Master

	add esp, 4;Jump error code.
	iret




	
